﻿/*                              
   Copyright 2011 Nils Kopal, Christopher Krüger, Simone Sauer, Dennis Nolte, Uni Duisburg-Essen

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
using System;

namespace Sharebert.DownloadLibrary.Interfaces
{
    /// <summary>
    /// A DownloadClient enables the user to download a file from a DownloadListener
    /// By using RequestFile(filename,filesize) the client asks the DownloadListener if it
    /// has a file fitting to name/size.
    /// </summary>
    public interface IDownloadClient
    {
        /// <summary>
        /// Ask the DownloadListener on the "other side" if it has such a file
        /// </summary>
        /// <param name="filename"></param>
        /// <param name="filesize"></param>
        void RequestFile(string filename, string tempfilename, int filesize);

        /// <summary>
        /// Stop actual download
        /// </summary>
        void StopDownload();

        /// <summary>
        /// The read/write timeout for the network communication
        /// </summary>
        int Timeout { get; set; }

        /// <summary>
        /// Fires if the DownloadListener tells us that is does not has the file
        /// </summary>
        event EventHandler<FileNotFoundEventArgs> FileNotFound;

        /// <summary>
        /// Fired if the download of the file is completed
        /// </summary>
        event EventHandler<FileCompletedEventArgs> FileCompleted;

        /// <summary>
        /// Fired each time a new part of the file is downloaded
        /// </summary>
        event EventHandler<DownloadStatusEventArgs> DownloadStatusChanged;

        /// <summary>
        /// Fired if the communication to the DownloadListener timed out
        /// </summary>
        event EventHandler<EventArgs> TimedOut;

        /// <summary>
        /// In case of an error this event is fired
        /// </summary>
        event EventHandler<ErrorArgs> ErrorOccurred;
    }
}
